//
//  SCPicCollectionViewCell.swift
//  weibo
//
//  Created by 阿城 on 15/12/11.
//  Copyright © 2015年 阿城. All rights reserved.
//

import UIKit

class SCPicCollectionViewCell: UICollectionViewCell {
    
    var picUrl: String?{
        didSet{
            imageView.sd_setImageWithURL(NSURL(string: picUrl!), placeholderImage: UIImage(named: "timeline_image_placeholder"))
            gifImageVIew.hidden = !picUrl!.containsString(".gif")
        }
    }
    lazy var imageView:UIImageView = {
        let imgView = UIImageView()
        imgView.contentMode = UIViewContentMode.ScaleAspectFill
        imgView.clipsToBounds = true
        return imgView
    }()
    // gif 图标
    private lazy var gifImageVIew: UIImageView = UIImageView(image: UIImage(named: "timeline_image_gif"))
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI(){
        addSubview(imageView)
        addSubview(gifImageVIew)
        imageView.snp_makeConstraints { (make) -> Void in
            make.edges.equalTo(UIEdgeInsetsZero)
        }
        gifImageVIew.snp_makeConstraints { (make) -> Void in
            make.trailing.equalTo(imageView)
            make.bottom.equalTo(imageView)
        }
    }
    
}
